#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QTimer * timer=new QTimer(this);
    id1=startTimer(1000);
    id2=startTimer(2000);
    id3=startTimer(10000);
    QObject::connect(ui->pushButton,SIGNAL(clicked(bool)),this,SLOT(timerUpdate()));
timer->start();
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::timerUpdate(){
   QDateTime  ttime=QDateTime::currentDateTime();

   QString  dat=ttime.toString("yyyy-MM-dd hh:mm:ss dddd");

    ui->lineEdit->setText(dat);
    int  rand=qrand()%300;
    ui->lineEdit->move(rand,rand);
}

void MainWindow::timerEvent(QTimerEvent *event)
{
   if(event->timerId()==id1)
   {

       ui->statusBar->showMessage(tr("hi welcome "),20000);
   }

   else if(event->timerId()==id2)
   {
       ui->statusBar->showMessage(tr("hi id2"));
   }
   else{
     //qApp->quit();

   }



}
